// 配置
// noinspection JSUnusedLocalSymbols

// 选择的界面主题
import {StorageUtils} from "@ginstone/common-utils/dist/src/utils/StorageUtils";
import {themes} from "@/assets/js/Themes";

const THEME_KEY = "UI:theme"

export default {
    namespaced: true,
    state: {
        // 当前主题
        theme: undefined,
    },
    mutations: {
        method(state, payload) {

        },
        // 加载主题
        loadTheme(state, payload) {
            state.theme = StorageUtils.get(THEME_KEY) || themes[0].value
        },
        // 修改主题
        setTheme(state, theme) {
            state.theme = theme
            StorageUtils.put(THEME_KEY, theme)
        },
    },
    actions: {
        method: ({dispatch, commit, state, rootGetters}, payload) => {

        },
    },
    getters: {
        // 根据行号决定该行的主题class
        getRowClass: (state) => (index) => {
            if (index % 2 === 0) {
                return state.theme + "-dark"
            }
            return state.theme + "-light"
        },
        // 返回主题背景class
        getBackgroundClass: (state) => {
            return state.theme + "-background"
        },
    },
}